<?php

/**
 * WeEngine System
 *
 * (c) We7Team 2021 <https://www.w7.cc>
 *
 * This is not a free software
 * Using it under the license terms
 * visited https://www.w7.cc for more details
 */

class DemoTpWechatServiceProvider extends \ProviderAbstract
{
    public function register()
    {
        // 适配TP框架
        $_SERVER['DOCUMENT_ROOT'] = MODULE_ROOT . DIRECTORY_SEPARATOR . 'public';
        $_SERVER['PATH_INFO']     = get_front_string('?', AppData::getUri());
        if ('/' === $_SERVER['PATH_INFO']) {
            unset($_SERVER['PATH_INFO']);
        }
        $_SERVER['REQUEST_URI']     = AppData::getUri();
        $_SERVER['SCRIPT_NAME']     = '/index.php';
        $_SERVER['PHP_SELF']        = '/index.php' . ($_SERVER['PATH_INFO'] ?? '');
        $_SERVER['PATH_TRANSLATED'] = MODULE_ROOT . '/public' . ($_SERVER['PATH_INFO'] ?? '');
        $_SERVER['SCRIPT_FILENAME'] = MODULE_ROOT . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'index.php';
        //这里放一些全局的变量可在应用内使用
        $GLOBALS['module_name'] = $this->moduleName;
    }

    public function boot()
    {
        require MODULE_ROOT . '/public/index.php';
    }
}
